package com.slowfly.rule.engine.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum StrategyStatusEnum {

    OFFLINE(1, "下线"),
    MARK(2, "标记"),
    ONLINE(3, "上线"),
    FUSE(4, "熔断");

    private final Integer code;
    private final String name;

    public static String getNameByCode(Integer code) {
        for (StrategyStatusEnum strategyStatusEnum : StrategyStatusEnum.values()) {
            if (Objects.equals(strategyStatusEnum.code, code)) {
                return strategyStatusEnum.name;
            }
        }
        return null;
    }

    public static boolean isOnline(Integer status) {
        return ONLINE.getCode().equals(status);
    }

    public static boolean isNotOffline(Integer status) {
        return !OFFLINE.getCode().equals(status);
    }
}
